import datetime

from sqlalchemy import Column, String, Text, DateTime, SmallInteger, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
from database import Base  # 从 main.py 导入共享的 Base


class Question(Base):
    __tablename__ = 'questions'

    question_id = Column(String(36), primary_key=True)  # 问题唯一ID (UUID)
    interview_id = Column(String(36)) # 所属面试ID
    resume_id = Column(String(36))  # 基于哪份简历生成
    question_text = Column(Text, nullable=False)  # 问题内容
    question_type = Column(String(50))  # 问题类型
    generated_time = Column(DateTime, default=datetime.datetime.now)  # Python端默认值
    difficulty_level = Column(SmallInteger)  # 难度等级 1~5
    question_order = Column(SmallInteger)  # 新增字段：问题顺序，由 id 字段赋值

    # # 可选关系映射（如果存在 Interview 和 Resume 模型）
    # interview = relationship("Interview", back_populates="questions")
    # resume = relationship("Resume", back_populates="questions")
